<?
	$matchs = fgsMatchs::getLast(false, false, array('login'=>$user['login']));
?>
<h2><?=sprintf(tr('Player : %s'), $user['login'])?></h2>
<p class="backpage"><?=fgsBase::linkPage(tr('&laquo; Back to players list'), 'players')?></p>
<p>
<?
	$l = new htmlList();
	$l->add(tr('Total matchs played'), count($matchs));
	$l->add(tr('Last login'), fgsUtils::formatDate($user['dt_lastlogin']));
	$l->add(tr('Last activity'), fgsUtils::formatDate($user['dt_lastactivity']));
	echo $l->render();
?>
</p>
<h3><?=tr('Latest Matchs')?></h3>
<?
	$table = new htmlTable();
	$table->setHeader('game', array(
		'width' => '16px',
	));
	$table->setHeader('id', array(
		'title' => '#',
		'width' => '7ex',
	));
	$table->setHeader('date', array(
		'title' => tr('Started'),
	));
	$table->setHeader('duration', array(
		'title' => tr('Duration'),
		'width' => '20ex',
	));
	$table->setHeader('status', array(
		'title' => tr('Status'),
		'width' => '10ex',
	));
	$table->setHeader('count', array(
		'title' => tr('Nb'),
		'width' => '3ex',
	));

	if (is_array($matchs)) {

		foreach ($matchs as $k=>$match) {
			
			if ($match['match_status_ret'] == -1) 
				$table->setLineParam('class', 'disabled'); 

			$table->set('id', fgsBase::linkPage('#'.$k, 'match', array($k)));
			$table->set('date', fgsUtils::formatDate($match['match_datecreate']));
			$table->set('duration', fgsUtils::formatSeconds($match['match_duration']));
			$table->set('status', $match['match_status']);
			$table->set('count', $match['nb_players']);

			$table->set('game', fgsBase::linkPage(
				sprintf('<img src="%s" alt="%s"/>', fgsBase::link('game', array($match['game_gid'], 'logo', 'icon16')), $match['game_name']),
				'game', array($match['game_gid'])
			));

			
			$table->push();
		}
		
		echo $table->render('550px');
	} else {
		echo tr('No matchs yet.');
	}

